#coding=utf-8
import re,sys

def gen_jifang(ipaddr):
	
	iprec=r"((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)"
	if not re.search(iprec,ipaddr):
		return None
	
	ips=ipaddr.split('.')
	if int(ips[0]) != 10:
		return None
	elif int(ips[1]) >= 0 and int(ips[1]) <= 15:
		return "大商所"
	elif int(ips[1]) >= 16 and int(ips[1]) <= 31:
		return "郑商所"
	elif int(ips[1]) >= 32 and int(ips[1]) <= 79:
		return "上期所"
	elif int(ips[1]) >= 80 and int(ips[1]) <= 95:
		return "大商所"
	elif int(ips[1]) >= 96 and int(ips[1]) <= 111:
		return "郑商所"
	elif int(ips[1]) == 116:
		if int(ips[2]) >= 129 and int(ips[2]) <= 131:
			return "深证通"
		elif int(ips[2]) == 132:
			return "大连飞创"
		elif int(ips[2]) == 133:
			return "上证通"
		elif int(ips[2]) >= 134 and int(ips[2]) <= 137:
			return "数讯"
		elif int(ips[2]) == 138:
			return "北京飞创"
		elif int(ips[2]) >= 140 and int(ips[2]) <= 143:
			return "移动金桥"
		elif int(ips[2]) >= 144 and int(ips[2]) <= 147:
			return "数讯"
		elif int(ips[2]) >= 160 and int(ips[2]) <= 167:
			return "移动金桥"
		else:
			return None
	elif int(ips[1]) == 117:
		if int(ips[2]) == 133:
			return "上证通"
		elif int(ips[2]) >= 134 and int(ips[2]) <= 137:
			return "数讯"
		elif int(ips[2]) >= 140 and int(ips[2]) <= 143:
			return "移动金桥"
		elif int(ips[2]) >= 144 and int(ips[2]) <= 147:
			return "数讯"
		else:
			return None
	elif int(ips[1]) == 118:
		return "上期技术"
	elif int(ips[1]) >= 128 and int(ips[1]) <= 143:
		return "上期所"
	elif int(ips[1]) >= 160 and int(ips[1]) <= 175:
		return "大商所"
	elif int(ips[1]) >= 176 and int(ips[1]) <= 191:
		return "郑商所"
	elif int(ips[1]) == 210:
		if int(ips[2]) >= 0 and int(ips[2]) <= 7:
			return "上期技术"
		elif int(ips[2]) == 8:
			return "北京飞创"
		elif int(ips[2]) == 12:
			return "大连飞创"
		else:
			return None
	elif int(ips[1]) == 213:
		if int(ips[2]) >= 0 and int(ips[2]) <= 7:
			return "上期技术"
		elif int(ips[2]) == 8:
			return "上证通"
		else:
			return None
	elif int(ips[1]) >= 240 and int(ips[1]) <= 255:
		return "保证金"
	else:
		return None

if __name__ == "__main__":

	#托管机房与三所
	#保证金
	#北京飞创
	#大连飞创
	#大商所
	#上期技术
	#上期所
	#上证通
	#深证通
	#数讯
	#移动金桥
	#郑商所
	jifang_loginmember={
		'bzj'=0,
		'bjfc'=0,
		'dlfc'=0,
		'dss'=0,
		'sqjs'=0,
		'sqs'=0,
		'szt'=0,
		'sx'=0,
		'ydjq'=0,
		'zss'=0
	}
	
	
	
	
	ipaddr=sys.argv[1]
	jifang=gen_jifang(ipaddr)
	if jifang==None:
		if re.match("^10.113|^10.114|^10.115|^10.116|^10.117",ipaddr):
			jifang="外高桥直连"
		elif re.match("^10.209|^10.211|^10.212|^10.213|^10.214",ipaddr):
			jifang="张江直连"
		else:
			jifang="未知"
	print jifang
	
	
	